package com.cloudpark.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloudpark.model.entity.Menu;
import com.cloudpark.model.entity.NavMenu;
import com.cloudpark.model.mapper.MenuMapper;
import com.cloudpark.model.mapper.NavMenuMapper;
import com.cloudpark.model.mapper.RoleMenuMapper;
import com.cloudpark.service.MenuService;

@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private NavMenuMapper navMenuMapper;
    @Autowired
    private MenuMapper menuMapper;
    @Autowired
    private RoleMenuMapper roleMenuMapper;

    @Override
    public List<NavMenu> findNavMenus(NavMenu param) {
        return navMenuMapper.selectBySelective(param);
    }

    @Override
    public List<Menu> findMenus(Menu param) {
        return menuMapper.selectBySelective(param);
    }

    @Override
    public Menu findMenuById(Long id) {
        return menuMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Menu> findMenusByParentId(Long parentId) {
        return menuMapper.selectByParentId(parentId);
    }

    @Override
    public List<Menu> findMenusByNavId(Long navMenuId) {
        return menuMapper.selectByNavId(navMenuId);
    }

    @Override
    public List<Long> findMenuIdsByRoleIds(List<Long> roleIds) {
        return roleMenuMapper.selectByRoleIds(roleIds);
    }

    @Override
    public NavMenu findNavMenuById(Long id) {
        return navMenuMapper.selectByPrimaryKey(id);
    }

}
